package com.lvkerry.orderfood.controller


import com.lvkerry.orderfood.api.ApiBean
import com.lvkerry.orderfood.entity.UserEntity
import com.lvkerry.orderfood.service.PersonService
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseBody


@Controller
@RequestMapping("/person")
class PersonController(private val personService: PersonService) {


    @ResponseBody
    @PostMapping("/addPerson")
    fun addPerson(person: UserEntity): ApiBean {
        return personService.addPerson(person)
    }

    @ResponseBody
    @PostMapping("/deletePersonById")
    fun deletePersonById(id: Long): ApiBean {

        return personService.deletePersonById(id)
    }

    @ResponseBody
    @PostMapping("/deletePersonByJobNo")
    fun deletePersonByJobNo(jobNo: String): ApiBean {
        return personService.deletePersonByJobNo(jobNo)
    }

    @ResponseBody
    @PostMapping("/findAllPerson")
    fun findAllPerson(): ApiBean {
        return personService.findAllPerson()
    }


}